﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_panel_TimKiem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["login_admin"] == null)
        {
            Response.Redirect("Index.aspx");
        }
    }

    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        dropBieuMau.Items.Clear();
        dropNam.Items.Clear();
        dropBieuMau.Items.Add("Xin chọn");
        dropNam.Items.Add("Xin chọn");

        if (radGroup.SelectedIndex == 0)
        {
           
            //
            for (int i = 1; i <= 14; i++)
            {

                dropBieuMau.Items.Add("Biểu Mẫu " + i.ToString("D2"));
            }

            for (int j = 2013; j <= DateTime.Now.Year; j++)
            {
                dropNam.Items.Add(j.ToString());
            }
          
        }
        else if (radGroup.SelectedIndex == 1)
        {
            //
            for (int i = 1; i <= 8; i++)
            {

                dropBieuMau.Items.Add("Phụ Lục " + i.ToString("D2"));
            }

            for (int j = 2013; j <= DateTime.Now.Year; j++)
            {
                dropNam.Items.Add(j.ToString());
            }
        }

        dropNam.SelectedIndex = 0;
        dropBieuMau.SelectedIndex = 0;

    }

    protected void btnTimKiem_Click(object sender, EventArgs e)
    {
        // kiem tra logic
        try
        {
            if (dropBieuMau.SelectedIndex == 0 || dropNam.SelectedIndex == 0 || radGroup.SelectedItem.ToString() == "")
            {
                Response.Write("<script language='JavaScript'> alert('Vui lòng chọn đầy đủ thông tin trước khi tìm'); </script>");
                return;
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script language='JavaScript'> alert('Vui lòng chọn đầy đủ thông tin trước khi tìm'); </script>");
            return;
        }
        
        // nếu chọn doanh nghiệp
        if (radGroup.SelectedIndex == 0)
        {
            Response.Redirect("ThongKe/frmThongKe_BieuMau_" + dropBieuMau.SelectedItem.ToString().Substring(dropBieuMau.SelectedItem.ToString().Length - 2, 2)+".aspx?nam="+dropNam.SelectedItem.ToString());
        }
        else if (radGroup.SelectedIndex == 1)
        {
            Response.Redirect("ThongKe/frmThongKe_PhuLuc_" + dropBieuMau.SelectedItem.ToString().Substring(dropBieuMau.SelectedItem.ToString().Length - 2, 2) + ".aspx?nam=" + dropNam.SelectedItem.ToString());
        }

    }
}